// 导入vue
import Vue from "vue";
// 导入路由
import VueRouter from "vue-router";

// 导入页面组件
import HomeContent from '@/view/Home.vue'
import Ranking from '@/view/TRanking.vue'
import ActivityInfo from '@/view/TActivityInfo.vue'
import Search from '@/view/TSearch.vue'
import AddTickets from '@/view/AddTickets.vue'

Vue.use(VueRouter)


// 创建路由

const router = new VueRouter({
        mode: 'hash',
        routes: [{
                path: '/',
                name: 'Home',
                component: HomeContent,
                meta: {
                    index: 0, // 用于匹配TabBar索引
                    title: '首页'
                }
            },
            {
                path: '/ranking',
                name: 'Ranking',
                component: Ranking,
                meta: {
                    index: 1,
                    title: '排行榜'
                }
            },
            {
                path: '/activity',
                name: 'ActivityInfo',
                component: ActivityInfo,
                meta: {
                    index: 2,
                    title: '活动说明'
                }
            },
            {
                path: '/search',
                name: 'Search',
                component: Search,
                meta: {
                    index: 3,
                    title: '搜索'
                }
            },
            // 打赏列表
            // {
            //     path: '/AddTickets',
            //     name: 'AddTickets',
            //     component: AddTickets,
            //     meta: {
            //         index: 3,
            //         title: '搜索'
            //     }
            // },
            // 重定向到首页
            {
                path: '/:pathMatch(.*)*',
                redirect: '/'
            }
        ]
    })
    //解决点击过快出现的导航报错
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
    return originalPush.call(this, location).catch(err => err)
}

export default router